import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class SocketDemo02 {
    public static void main(String[] args) throws IOException {
        // 创建一个套接对象，并连接127.0.0.1服务器地址9000端口
        Socket socket = new Socket("192.168.1.43", 9001);
        // 获取输出流对象
        OutputStream outputStream = socket.getOutputStream();
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("请输入内容");
            String s = scanner.next();
            outputStream.write(s.getBytes());
            if (s.equals("88")) {
                break;
            }
        }
        if (!socket.isClosed()) {
            socket.close();
        }
    }
}
